'use strict'
/**
 * artical
 */

module.exports = (app) => {
	const { STRING, INTEGER, UUID, NOW, DATE, UUIDV4, TEXT } = app.Sequelize

	const Artical = app.model.define(
		'articals',
		{
			id: {
				type: UUID,
				primaryKey: true,
				allowNull: true,
				autoIncrement: true,
				comment: '文章Id',
			},
			title: {
				type: STRING,
			},
			content: TEXT,
			summary: STRING,
			category_id: INTEGER,
			thumbnail: STRING,
			is_top: STRING,
			status: STRING,
			view_count: INTEGER,
			is_comment: STRING,
			create_by: STRING,
			createdAt: DATE,
			updatedAt: DATE,
			deletedAt: DATE,
		},

		{
			// 去除createAt，updateAt
			timestamps: true,
			// 实例对应的表名
			tableName: 'articals',
		}
	)
	Artical.associate = function () {
		Artical.belongsTo(app.model.Categorical, {
			foreignKey: 'category_id',
		})
	}
	return Artical
}
